package workflow.dto;

import java.util.HashMap;
import java.util.Map;

public class WorkflowConnection {
	
	/** wejscie */
	private String source;
	
	/** wyjscia */
	private Map<Integer, String> targets;
	
	/** konstruktor dla polaczen pojedynczych */
	public WorkflowConnection(String source, String target) {
		super();
		this.source = source;
		this.targets = new HashMap<Integer, String>();
		targets.put(0, target);
	}
	
	/** konstruktor dla polaczen podwojnych */
	public WorkflowConnection(String source, String targetIfTrue,
			String targetIfFalse) {
		super();
		this.source = source;
		this.targets = new HashMap<Integer, String>();
		targets.put(0, targetIfFalse);
		targets.put(1, targetIfTrue);
	}
	
	/** konstruktor dla polaczen wielokrotnych */
	public WorkflowConnection(String source, Map<Integer, String> targets) {
		super();
		this.source = source;
		this.targets = targets;
	}

	public String getSource() {
		return source;
	}
	
	public String getTarget(int key){
		return targets.get(key);
	}

	public WorkflowConnection getCopy() {
		Map<Integer, String> newTargets = new HashMap<Integer, String>(targets);
		WorkflowConnection conn = new WorkflowConnection(this.source, newTargets);
		return conn;
	}

}
